﻿Imports System.Runtime.InteropServices

Public Class Form
    Inherits WinFormComponent.RegularForm

    'Constant
    'Drop Shadow
    Protected Const DropShadow As Integer = &H20000
    'Move Window without Caption Bar
    Public Const WmNclButtonDown As Integer = &HA1
    Public Const HtCaption As Integer = &H2

    'static Methods
    'Move Window Without Any Caption Bar
    <DllImportAttribute("user32.dll")> _
    Public Shared Function SendMessage(hWnd As IntPtr, Msg As Integer, wParam As Integer, lParam As Integer) As Integer
    End Function
    <DllImportAttribute("user32.dll")> _
    Public Shared Function ReleaseCapture() As Boolean
    End Function

    Public Sub New()

        ' This call is required by the designer.
        Me.InitializeComponent()
        Me.InitializeContentControls()

        ' Add any initialization after the InitializeComponent() call.
        Me.HomeControl.MainForm = Me

        Me.Invalidate()
        Me.SetStyle(ControlStyles.OptimizedDoubleBuffer Or
                     ControlStyles.UserPaint Or
                     ControlStyles.AllPaintingInWmPaint, True)
    End Sub

    Private Sub CaptionPanel_MouseDown(sender As Object, e As MouseEventArgs) Handles CaptionPanel.MouseDown
        Me.Opacity = 0.5
        If e.Button = MouseButtons.Left Then
            'Move Window Without Any Caption Bar
            ReleaseCapture()
            SendMessage(Handle, WmNclButtonDown, HtCaption, 0)

            'After the Mouse Release                
            Me.Opacity = 1.0
        End If
    End Sub

    Private Sub MinimizeButton_Click(sender As System.Object, e As System.EventArgs) Handles MinimizeButton.Click
        Me.WindowState = FormWindowState.Minimized
    End Sub

    Private Sub CloseButton_Click(sender As System.Object, e As System.EventArgs) Handles CloseButton.Click
        Me.Close()
        Me.Dispose()
    End Sub

    Private Sub BackButton_Click(sender As System.Object, e As System.EventArgs) Handles BackButton.Click
        Me.HideAllContentControls()
        Me.HomeControl.Visible = True
        Me.BackButton.Visible = False
        Me.HeadingLabel.Text = "home"
    End Sub

    Public Sub HideAllContentControls()
        For Each Controls As Control In Me.ContentPanel.Controls
            Controls.Visible = False
        Next
    End Sub
End Class